<?php
    
    namespace App\Observers;

    use App\System\Cis\Model\CisAdmin;
    use App\System\Log\Repositories\LogAdminRepository;

    class CisAdminObserver
    {

        /**
         * 监听用户更新的事件。
         *
         * @param  CisAdmin  $cisAdmin
         * @return void
         */
        public function updated(CisAdmin $cisAdmin)
        {
            $data['type'] = 1;
            $data['log_info'] = '修改管理员信息';
            if($cisAdmin->isDirty(['status'])){
                $data['log_info'] = '修改管理员状态';
            }
            $logAdmin = LogAdminRepository::getInstance();
            $logAdmin->saveAdminLog($data);
        }

        /**
         * @param CisAdmin $cisAdmin
         */
        public function created(CisAdmin $cisAdmin)
        {
            $data['type'] = 1;
            $data['log_info'] = '新增管理员';
            $logAdmin = LogAdminRepository::getInstance();
            $logAdmin->saveAdminLog($data);
        }

        /**
         * @param CisAdmin $cisAdmin
         */
        public function deleted(CisAdmin $cisAdmin)
        {
            $data['type'] = 1;
            $data['log_info'] = '删除管理员';
            $logAdmin = LogAdminRepository::getInstance();
            $logAdmin->saveAdminLog($data);
        }

    }
     
    